home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
crc.lqr
/
CRCCALC.ASM
< prev
Wrap
Assembly Source File
|
1985-06-03
|
3KB
|
77 lines
PAGE 64,132
;******************************************************************************
;
; CRCCALC - Calculate CRC for block of data
;
;******************************************************************************
;
;
; Modified 31 May, 1984 for L-model of Lattice C V2.00
;
; John F. Ratti
; 12 May, 1984
;
;******************************************************************************
;
; c/o Computer Power, Inc.
; P. O. Box 2388
; Jacksonville, FL 32231
; (904) 350-1400
;
;******************************************************************************
_PROG SEGMENT BYTE
PUBLIC CRCCALC
ASSUME CS:_PROG
CRCCALC PROC FAR
PUSH BP ;save BP
PUSH DS ;save DS 12MAY84
MOV BP,SP ;get stack pointer
MOV BX,[BP+8] ;get previous CRC
MOV CX,[BP+14] ;get length of data
MOV DX,1021H ;load constant for CCITT CRC (replace
;"1021H" with "8005H" for IBM SYNC CRC)
LDS SI,DWORD PTR [BP+10] ;get long pointer to data 12MAY84
CLD ;we will work from low to high address
A0: LODSB ;get a data byte
B0: SHL AL,1 ;move high-order bit into carry
RCL BX,1 ;shift carry bit into CRC
JNB B1 ;if carry is 0, bypass XOR
XOR BX,DX ;XOR w/CCITT CRC constant
B1: SHL AL,1 ;move high-order bit into carry
RCL BX,1 ;shift carry bit into CRC
JNB B2 ;if carry is 0, bypass XOR
XOR BX,DX ;XOR w/CCITT CRC constant
B2: SHL AL,1 ;move high-order bit into carry
RCL BX,1 ;shift carry bit into CRC
JNB B3 ;if carry is 0, bypass XOR
XOR BX,DX ;XOR w/CCITT CRC constant
B3: SHL AL,1 ;move high-order bit into carry
RCL BX,1 ;shift carry bit into CRC
JNB B4 ;if carry is 0, bypass XOR
XOR BX,DX ;XOR w/CCITT CRC constant
B4: SHL AL,1 ;move high-order bit into carry
RCL BX,1 ;shift carry bit into CRC
JNB B5 ;if carry is 0, bypass XOR
XOR BX,DX ;XOR w/CCITT CRC constant
B5: SHL AL,1 ;move high-order bit into carry
RCL BX,1 ;shift carry bit into CRC
JNB B6 ;if carry is 0, bypass XOR
XOR BX,DX ;XOR w/CCITT CRC constant
B6: SHL AL,1 ;move high-order bit into carry
RCL BX,1 ;shift carry bit into CRC
JNB B7 ;if carry is 0, bypass XOR
XOR BX,DX ;XOR w/CCITT CRC constant
B7: SHL AL,1 ;move high-order bit into carry
RCL BX,1 ;shift carry bit into CRC
JNB B8 ;if carry is 0, bypass XOR
XOR BX,DX ;XOR w/CCITT CRC constant
B8: LOOP A0 ;loop until all data processed
MOV AX,BX ;put CRC into return register
EXIT: POP DS ;get DS back 12MAY84
POP BP ;get BP back
RET ;return to caller
CRCCALC ENDP
_PROG ENDS
END
;****************************** end of CRCCALC.ASM ****************************